<?php
$error=array();
if(empty($_POST)==false){
    //执行if判断是否为空
$uname=isset($_REQUEST['uname'])?trim($_REQUEST['uname']):'';
$password=isset($_REQUEST['password'])?trim($_REQUEST['password']):'';
require "dbcon.php";
$sql="select * from tb_user where uname='{$uname}'";
$result=$db->query($sql);
$sum=$result->num_rows;
if($sum>0){
    $row=$result->fetch_array();
    if($row['password']==$password){
        session_start();
        $_SESSION['userinfo']=array('uid'=>$row['uid'],'uname'=>$row['uname']);
        header('location:index.php');//直接跳转
        die;
    }else{
         $error[]="密码错误！";
    }
}else {
       $error[]="用户名不存在！"; 
    }
    }
require "login_html.php";

